package com.ch.home.testMapper;

import com.ch.home.bean.Dish;
import com.ch.home.bean.DishAndSources;
import com.ch.home.mapper.restDishMapper.DishMapper;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.test.context.junit4.SpringRunner;

import java.util.LinkedList;

/**
 * Created by CHEN on 2019/8/26.
 */
@RunWith(SpringRunner.class)
@SpringBootTest
public class testDishMapper {


    @Autowired
    DishMapper dishMapper;


//    LinkedList<Dish> getDish(Dish dish);
//
//    int addDish(Dish dish);
//
//    int updateDish(Dish dish);

    @Test
    public void testGetDish() {

        System.out.println( dishMapper.getDish(new Dish( )));

        System.out.println(dishMapper.getDish(new Dish(1,null,null,null,null,null)) );
        System.out.println(dishMapper.getDish(new Dish(null,"番茄",null,null,null,null)) );
        System.out.println(dishMapper.getDish(new Dish(null,null,null,null,null,null)) );

    }

    @Test
    public void testAddDish(){

        System.out.println(dishMapper.addDish(new Dish(null,"杭州酱鸭4","这是一道非常非常好吃的杭州酱鸭",9,"杭帮菜",0)) );


    }
    @Test
    public void testUpdateDish(){

        System.out.println(dishMapper.updateDish(new Dish(3,"杭州酱鸭5","这是一道非常非常好吃的杭州酱鸭2",10,"杭帮菜",1)) );


    }


    @Test
    public void testGetDishAndSource(){
//         <!--LinkedList<Object> getDishAndSource(Dish dish);-->?\

        System.out.println("------------------" );
        LinkedList<DishAndSources> dishAndSource = dishMapper.getDishAndSource(new Dish(null, null, null, null, "杭帮菜", null));

        System.out.println( dishAndSource);
    }
}
